package ejb;

import java.util.Properties;

import javax.naming.Context;
import javax.naming.InitialContext;

import service.Greeting;

/**
 * EJB调用
 * 
 * @author Wangpeihu
 * @team [Never give up]
 * @since JDK1.6(建议)
 * @date 2010-2-11
 */

public class GreetingTest {

	public static void main(String[] args) throws Exception {

		Properties props = new Properties();

		// 垒石驱动
		props.setProperty(Context.INITIAL_CONTEXT_FACTORY,
				"org.jnp.interface.InitialContextFactory");
		// URL,jnp 是协议
		props.setProperty(Context.PROVIDER_URL, "jnp://localhost");

		Context context = new InitialContext(props);

		// 从服务器取
		Greeting service = (Greeting) context.lookup("GreetingImpl/remote");

		String res = service.sayHello("Java");
		System.out.println(res);

	}

}
